<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>hash散列表</title>
</head>
<body>
<input type="button" value="点击打印" id="print"/>
<div id="div"></div>
<script src="hash.js">z</script>
<script>
    var oBtn=document.getElementById("print");
    var oDiv=document.getElementById("div");
    var movies;
    oBtn.onclick=function(){
        new Promise(function(resolve,reject){
            var xhr=new XMLHttpRequest();
            xhr.open('GET','movies.txt',true);
            xhr.send(null);
            xhr.onreadystatechange=function () {
                if (xhr.status == 200 && xhr.readyState == 4) {
                    movies= xhr.responseText.split("\n");
                    resolve();
                }
            }
        }).then(function(){
            //oDiv.innerHTML=movies;
            var hTable=new HashTable();
            for(var i=0;i<movies.length;i++){
                hTable.put(movies[i]);
            }
            oDiv.innerHTML=hTable.showDistro();
        })
    }
</script>
</body>
</html>